create table Insurance
(
	 [InsuranceId] int identity(1, 1) primary key
	,[PartnerId] int
	,[InsuranceName] nvarchar(256)
	,[InsuranceLevel] nvarchar(128)
	,[InsuranceBegin] datetime
	,[SortDescription] nvarchar(256)
	,[DetailDescription] nvarchar(max)
	,[CreatedBy] int
	,[CreatedDate] datetime
	,[UpdatedBy] int
	,[UpdatedDate] datetime
	,[Status] int
)
go


CREATE PROCEDURE InsuranceGet
	@InsuranceId int
AS
SELECT *
FROM [Insurance]
WHERE [Insurance].[InsuranceId] = @InsuranceId
GO

CREATE PROCEDURE InsuranceList
AS
SELECT *
FROM [Insurance]
ORDER BY [InsuranceId] DESC
GO

CREATE PROCEDURE InsuranceInsert
	@PartnerId int
	,@InsuranceName nvarchar(256)
	,@InsuranceLevel nvarchar(128)
	,@InsuranceBegin datetime
	,@SortDescription nvarchar(256)
	,@DetailDescription nvarchar(max)
	,@CreatedBy int
	,@CreatedDate datetime
	,@UpdatedBy int
	,@UpdatedDate datetime
	,@Status int
AS

INSERT INTO Insurance (
	 [PartnerId]
	,[InsuranceName]
	,[InsuranceLevel]
	,[InsuranceBegin]
	,[SortDescription]
	,[DetailDescription]
	,[CreatedBy]
	,[CreatedDate]
	,[UpdatedBy]
	,[UpdatedDate]
	,[Status]
	
) VALUES (
	 @PartnerId
	,@InsuranceName
	,@InsuranceLevel
	,@InsuranceBegin
	,@SortDescription
	,@DetailDescription
	,@CreatedBy
	,@CreatedDate
	,@UpdatedBy
	,@UpdatedDate
	,@Status
	
)

select SCOPE_IDENTITY()
GO

CREATE PROCEDURE InsuranceUpdate
	@InsuranceId int, 
	@PartnerId int, 
	@InsuranceName nvarchar(256), 
	@InsuranceLevel nvarchar(128), 
	@InsuranceBegin datetime, 
	@SortDescription nvarchar(256), 
	@DetailDescription nvarchar(max), 
	@CreatedBy int, 
	@CreatedDate datetime, 
	@UpdatedBy int, 
	@UpdatedDate datetime, 
	@Status int 

AS

UPDATE Insurance SET
	   [PartnerId] = @PartnerId
	   ,[InsuranceName] = @InsuranceName
	   ,[InsuranceLevel] = @InsuranceLevel
	   ,[InsuranceBegin] = @InsuranceBegin
	   ,[SortDescription] = @SortDescription
	   ,[DetailDescription] = @DetailDescription
	   ,[CreatedBy] = @CreatedBy
	   ,[CreatedDate] = @CreatedDate
	   ,[UpdatedBy] = @UpdatedBy
	   ,[UpdatedDate] = @UpdatedDate
	   ,[Status] = @Status
WHERE [Insurance].[InsuranceId] = @InsuranceId
GO

CREATE PROCEDURE InsuranceDelete
	@InsuranceId int
AS
DELETE FROM Insurance
WHERE [Insurance].[InsuranceId] = @InsuranceId
GO